﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using DAO;
using System.Data.Sql;
using System.Data.SqlClient;

namespace BLL.test
{
    public class textBll
    {
        DataConnection dc = new DataConnection("server=.;uid=sa;pwd=123;database=Issue;");

        public DataTable getAllUser()
        {
            try
            {
                string strSql = "";
                return dc.ExecuteDataTable(strSql);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public bool CheckLogin(string userName, string userPwd)
        {
            try
            {
               // string strSql = "select * from test_User where userName='"+userName+"' and userPwd='"+userPwd+"'";
               //object ob = dc.ExecuteString(strSql);

               SqlParameter[] pas = new SqlParameter[]
               {
                new SqlParameter("@uname",userName),
                new SqlParameter("@upwd",userPwd)
            };

               //object ob = dc.ExecuteString(pas,SqlString.sp_test_Login);

               DataTable ob = dc.ExecuteDataTable(pas, SqlString.sp_test_Login);
                if (ob!=null)
                    return true;
                else
                    return false;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public DataTable GetAllUser()
        {
            try
            {
                return dc.ExecuteDataTableByProcedure(SqlString.sp_test_AllUser);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
    }
}
